package com.cd.hospital.www.web;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by weirdor on 2017/10/13.
 */
@RestController
@RequestMapping("/api")
public class ImageController {

//    /**
//     * 获取七牛上传token，由于之前只考虑上传图片，所以接口的url就体现了image，但后来上传类型变多了，所以该接口字面上的适用范围就变窄了（
//     * 虽然仍可用），所以添加上面的统一接口
//     */
//    @RequestMapping("/image/token/{bucketName}")
//    public Map<String, Object> tokenOld(HttpServletRequest request, HttpServletResponse response,
//                                        @PathVariable("bucketName") String bucketName,
//                                        @RequestParam(name = "type", required = false, defaultValue = "file") String type) {
//        Map<String, Object> map = new HashMap<String, Object>();
//
//        try {
//            map.put("uptoken", Qi.getToken(bucketName));
//        } catch (ZuihuiyouClientException e) {map.put("code", e.getErrorCode());
//            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
//            map.put("message", e.getMessage());
//        } catch (Exception e) {
//            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
//            e.printStackTrace();
//            map.put("message", e);
//        }
//        return map;
//    }

}
